package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.dto.RouteDto;
import com.ruoyi.system.service.IRouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: ZCJ
 * @date: 2024/06/24/11:09
 * @desc:
 */
@RestController
@RequestMapping("/route")
public class RouteController extends BaseController {
    @Autowired
    private IRouteService routeService;

    /**
     * 根据景点id获取路线
     * @param spotId
     * @return
     */
//    @GetMapping("/{spotId}")
//    public AjaxResult getRoutesBySpotId(@PathVariable("spotId") Integer spotId){
//        return routeService.getRoutesBySpotId(spotId);
//    }

    /**
     * 根据景点名称获取景点信息
     * @return
     */
    @GetMapping
    public TableDataInfo getRoutesBySpotName(@RequestParam(value = "spotName", required = false) String spotName){
        startPage();
        List<RouteDto> routes = routeService.getRoutesBySpotName(spotName);
        return getDataTable(routes);
    }

    /**
     * 根据路线id查询路线详情
     */
    @GetMapping("/{routeId}")
    public AjaxResult getRouteDetailByRouteId(@PathVariable("routeId") Integer routeId){
        return routeService.getRouteDetailByRouteId(routeId);
    }

}
